classdef TopologyDrawer
    properties
    end
    
    methods(Static)
        function draw(topology)
            cla;
            hold on;
            for i = 1 : topology.number_of_hap_nodes
               TopologyDrawer.draw_hap_point(topology, i);
               for j = 1:topology.number_of_hap_nodes
                   if topology.costs_matrix(i, j) ~= inf
                       TopologyDrawer.draw_line(topology.nodes(i), topology.nodes(j), ':', 'blue', 0.5);
                   end
               end
               for j = (topology.number_of_hap_nodes + 1):(topology.number_of_hap_nodes + topology.number_of_gap_nodes)
                   if topology.costs_matrix(i, j) ~= inf
                       TopologyDrawer.draw_line(topology.nodes(i), topology.nodes(j), ':', 'y', 2);
                   end
               end
            end
            
            for i = (topology.number_of_hap_nodes + 1) : (topology.number_of_hap_nodes + topology.number_of_gap_nodes)
               TopologyDrawer.draw_gap_point(topology, i);
            end
        end
       
       function draw_hap_point(topology, i)
           plot(topology.nodes(i).x_value, topology.nodes(i).y_value, '.');
           text(topology.nodes(i).x_value, topology.nodes(i).y_value+30, num2str(i), 'FontWeight', 'bold', 'FontSize', 18,'Color', [218, 112, 214]/255);
       end
       
       function draw_gap_point(topology, i)
           plot(topology.nodes(i).x_value, topology.nodes(i).y_value, '.', 'MarkerEdgeColor','g', 'MarkerFaceColor','g', 'MarkerSize', 30);
           text(topology.nodes(i).x_value, topology.nodes(i).y_value + 20, num2str(i), 'FontWeight', 'demi', 'Color', 'w');
       end
       
       function draw_line(node1, node2, line_style, color, line_width)
           line([node1.x_value node2.x_value], [node1.y_value, node2.y_value],...
               'Color',color,'LineWidth', line_width, 'LineStyle', line_style);
       end
       
       function clear_line(node1, node2)
           TopologyDrawer.draw_line(node1, node2, ':', 'blue', 0.5);
       end

       function draw_path(topology, path, line_style, color, line_width)
           if ~isempty(path)
               for i = 1:(length(path)-1)
                   TopologyDrawer.draw_line(topology.nodes(path(i)), topology.nodes(path(i+1)), line_style, color, line_width);
               end
           end
       end
    end
end